package ObjectOriented;

/**
 * record 关键字
 */
public class LearnRecord {
  public static void main(String[] args) {
    Point p = new Point(1, 2);
    System.out.println(p.x());
    System.out.println(p.y());
  }
}

record Point(int x, int y) {}

/**
 * 相当于以下代码的实现
 * public final class Point {
    private final int x;
    private final int y;

    public Point(int x, int y) {
      this.x = x;
      this.y = y;
    }

    public int x() {
      return this.x;
    }

    public int y() {
      return this.y;
    }
  }
 */